package com.mall.seckill.handle;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.fastjson.JSON;
import com.common.utils.R;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class SentinelUrlBlockHandler implements BlockExceptionHandler {

    @Override
    public void handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, BlockException e) throws Exception {
        R error = R.error(500,"稍后再试");
        response.getWriter().write(JSON.toJSONString(error));
    }
}
